package com.common.mysql;

/**
 * 存放mysql数据库需要的键值对，为了是方便mybatis动态插入字段方便
 */
public class KeyAndValuePair {
    /**
     * 操作符标识：
     * 0：存放的是单个值
     * 1：存放的是多个值
     * 2：存放的是操作符字符
     * 4：存放的是操作字段值
     * 5：存放的是字段值
     * 6：分页字段
     * 7：排序字段
     */
    private int operator;
    private String key;
    private Object value;

    private KeyAndValuePair(int operator, String key, Object value) {
        this.operator = operator;
        this.key = key;
        this.value = value;
    }

    private KeyAndValuePair(int operator, Object value) {
        this.operator = operator;
        this.value = value;
    }

    public static KeyAndValuePair build(int operator, String key, Object value) {
        return new KeyAndValuePair(operator, key, value);
    }

    public static KeyAndValuePair build(int operator, Object value) {
        return new KeyAndValuePair(operator, value);
    }

    public int getOperator() {
        return operator;
    }

    public void setOperator(int operator) {
        this.operator = operator;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public Object getValue() {
        return value;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return "[" + this.operator + ":" + this.key + ":" + this.value + "]";
    }
}
